package com.luginf.activities.view;

import com.luginf.adapter.SummaryELAdapter;
import com.luginf.mock.SummaryMock;

import com.luginf.activities.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnGroupExpandListener;

public class SummaryActivity extends Activity {

	private SummaryELAdapter mAdapter;
	private ExpandableListView list;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_summary);
		mAdapter = new SummaryELAdapter(getBaseContext(), SummaryMock.mockSummary(10));
		list = (ExpandableListView) findViewById(R.id.summaryList);
		list.setAdapter(mAdapter);
		list.setGroupIndicator(null);

		list.setOnGroupExpandListener(new OnGroupExpandListener() {
			public void onGroupExpand(int groupPosition) {
				int len = mAdapter.getGroupCount();
				for (int i = 0; i < len; i++) {
					if (i != groupPosition) {
						list.collapseGroup(i);
					}
				}
			}
		});
	}

}